package com.remote
{
	import mx.collections.ArrayCollection;

	public class CommonFunction
	{
		public function CommonFunction()
		{
		}
		
		public static function findInArrayColection(arrResultSearch:ArrayCollection, strColumn:String, strChar:Object):int
		{ 
			var index:int = 0;
			var matches : Array = arrResultSearch.source.filter( findFunction(strColumn,strChar) );
			if(matches.length==0)
			{
				index = -1;
			}
			else
			{
				index = arrResultSearch.getItemIndex(matches[0]);
			}	
			return index;
		}
		
		private static function findFunction(propertyName:String,propertyValue:*):Function
		{
			return function( element : *, index : int, array : Array ) : Boolean
			{
				return element[propertyName] == propertyValue;
			}
		}
	}
}